<?php
defined('IN_IXDCW') or exit('Access Denied');
$do = new CompanyAdmin;
$menus = array (
	array('创建列表', '?moduleid='.$moduleid.'&file=list'),
	array('待审核', '?moduleid='.$moduleid.'&file=audit'),
	array(VIP.'管理', '?moduleid='.$moduleid.'&file=vip'),
	array('会员列表', '?moduleid=2'),
);
$this_forward = '?moduleid='.$moduleid.'&file='.$file;

if($_catids || $_areaids) {
	if(isset($userid)) $itemid = $userid;
	if(isset($member['areaid'])) $post['areaid'] = $member['areaid'];
	require DT_ROOT.'/admin/admin_check.inc.php';
}

switch($action) {
	case 'delete':
		if(!CompanyAdmin::deleteDoc($did)) Prompt::message('删除报错','goback');
		dmsg('删除成功', $forward);
		break;

	case 'authority':
		if(!$do->authorityDoc($did,$authority)) Prompt::message('启用报错','goback');
		dmsg('启用操作成功', $forward);
		break;

	case 'level':
		if(!$do->levelDoc($did,$level)) Prompt::message('推荐报错','goback');
		dmsg('推荐操作成功', $forward);
		break;
	default:
		$sfields    = array('按条件', '公司名');
		$dfields    = array('keyword', 'title');
		$MS         = PCache::read('module-2.php');

		$modes      = explode('|', '经营模式|'.$MS['com_mode']);
		$types      = explode('|', '公司类型|'.$MS['com_type']);
		$sizes      = explode('|', '公司规模|'.$MS['com_size']);
		$audits     = array('全部词条','未审核词条');

		$thumb      = isset($thumb) ? intval($thumb) : 0;
		$level      = isset($level) ? intval($level) : 0;
		$mincapital = isset($mincapital) ? dround($mincapital) : '';
		$mincapital or $mincapital = '';
		$maxcapital = isset($maxcapital) ? dround($maxcapital) : '';
		$maxcapital or $maxcapital = '';
		$areaid = isset($areaid) ? intval($areaid) : 0;
		isset($mode)    && isset($modes[$mode])     or $mode = 0;
		isset($type)    && isset($types[$type])     or $type = 0;
		isset($size)    && isset($sizes[$size])     or $size = 0;
		isset($audit)   && isset($audits[$audit])   or $audit = 0;

		$fields_select  = dselect($sfields, 'fields', '', $fields);
		$type_select    = dselect($types, 'type', '', $type);
		$size_select    = dselect($sizes, 'size', '', $size);
		$audit_select   = dselect($audits,'audit','',$audit);

		$condition = " d.did=c.did ";

		if($kw)         $condition .= " AND d.title LIKE '%$kw%'";
		if(isset($catid) && $catid!=''){
			$category = PCache::read('category-25.php');
			if($category[$catid]['arrchildid']){
				$categoryid = $category[$catid]['arrchildid'];
				$condition .= " AND c.catid IN($categoryid)";
			}else{
				$condition .= " AND c.catid IN($catid)";
			}
		}


		if($areaid)     $condition .= ($ARE['child']) ? " AND d.company_areaid IN (".$ARE['arrchildid'].")" : " AND d.company_areaid=$areaid";
		if($type)       $condition .= " AND d.company_type=$type";
		if($size)       $condition .= " AND d.company_size='$size'";
		if($audit)      $condition .= " AND d.authority!='$audit'";
		if($thumb)      $condition .= " AND d.company_thumb<>''";
		if($level)      $condition .= " AND d.level<>0";
		if($uid)        $condition .= " AND d.authorid=$uid";
		if($username)   $condition .= " AND d.author='$username'";
		if($fromtime)   $condition .= " AND d.time>".(strtotime($fromtime.' 00:00:00'));
		if($totime)     $condition .= " AND d.time<".(strtotime($totime.' 23:59:59'));

		$lists = $do->getList($condition);
		include tpl('list', $module);
		break;

}